<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" indent="yes"/>
    <xsl:param name="userId">0</xsl:param>

    <xsl:template match="/">
        <html>
            <body>
                <xsl:apply-templates select="feeds">
                </xsl:apply-templates>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="feeds">
        <ul class="feed-list">
            <xsl:for-each select="feed">
                <xsl:sort select="addedDate" order="descending"/>
                <xsl:if test="not(position() > 5)">
                    <li>
                        <xsl:variable name="des" select="decription"/>
                        <a href="" class="rss-name" title="{$des}">
                            <xsl:value-of select="title"/>
                        </a>
                        <xsl:choose>
                            <xsl:when test="userlist/userId=$userId">
                                    <a class="disabled-button">Đã có</a>
                            </xsl:when>
                            <xsl:otherwise>
                                    <form action="addFeedToUserList.action" method="post">
                                        <input type="hidden" name="rssID">
                                            <xsl:attribute name="value">
                                                <xsl:value-of select="feedId"/>
                                            </xsl:attribute>
                                        </input>
                                        <input type="hidden" name="returnTo" value="index" />
                                        <input type="submit" class="button" value="Thêm feed" />
                                    </form>
                            </xsl:otherwise>
                        </xsl:choose>
                    </li>
                </xsl:if>
            </xsl:for-each>
        </ul>
    </xsl:template>

</xsl:stylesheet>
